package com.mxpio.erp.common.util;

import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.Map;

public class JacksonMapUtils {


    private static final ObjectMapper mapper = new ObjectMapper();

    public static Map<String, Object> convertObjectToMap(Object obj) {
        try {
            // 先转成 JSON 字符串
            String json = mapper.writeValueAsString(obj);
            // 再转成 Map
            return mapper.readValue(json, Map.class);
        } catch (Exception e) {
            throw new RuntimeException("转换失败", e);
        }
    }

}
